Minimum Spanning Trees (MST)
A Minimum Spanning Tree (MST) finds the cheapest way to connect all vertices in a weighted, undirected graph . This is a global optimization problem, distinct from finding the shortest path between two specific points.
- What it is: An MST is a subgraph that connects all vertices together with the minimum possible total edge weight, without forming any cycles.
- Property 1: Spanning - The subgraph must connect all vertices of the original graph.
- Property 2: Acyclic - The subgraph must not contain any cycles, which is the definition of a tree structure.
- Property 3: Edge Count - A tree connecting vertices will always have exactly edges.
- Property 4: Minimum Weight - The sum of all edge weights in the tree, , is minimized.
- Transition from SSSP: While Dijkstra's algorithm finds the shortest path from a single source, MST algorithms like Prim's use a similar greedy approach to build a minimal tree connecting all nodes.
MST vs. Shortest Path (SSSP)
| Feature | Minimum Spanning Tree (MST) | Single-Source Shortest Path (SSSP) |
|---|---|---|
| Goal | Connect ALL vertices with minimum total weight. | Find shortest paths from ONE source to all others. |
| Output | A single tree (a subgraph). | A set of paths. |
| Edge Count | Exactly . | Varies, not fixed. |
| Structure | Guaranteed to be acyclic. | The original graph can have cycles. |
📝 Interactive Quiz
1. What is the primary goal of an MST algorithm?
2. For a connected graph with 20 vertices (), how many edges will its MST have?
3. Which of the following is a required property of a Minimum Spanning Tree?